# -*- coding: utf-8 -*-#

#-------------------------------------------------------------------------------
# Name:         ljy
# Description:  
# Author:       lenovo
# Date:         2018/11/22
#-------------------------------------------------------------------------------

import sys
import bs4

urls = []
html = open('index.html', 'r', encoding='utf-8').read()
soup = bs4.BeautifulSoup(html, 'html5lib')
for i in range(1, 7):
    elems = soup.select('#navBody .navCont .cols0'+ str(i) + ' li a')[:6];
    for e in elems:
        urls.append('http://www.xinhuanet.com/' + e['href'])
print(urls)

html = open('test1.html', 'r', encoding='utf-8').read()
soup = bs4.BeautifulSoup(html, 'html5lib')
count = 0
for i in range(1, 7):
    elems = soup.select('#showData0 .clearfix h3 a');
    for e in elems:
        count += 1
        print(e['href'])
print(count)